﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using FCS;

namespace Applications.Test
{
    /// <summary>
    /// Summary description for MathematicsTests
    /// </summary>
    [TestClass]
    public class MathematicsTests : Functional
    {
        public MathematicsTests()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        [TestMethod]
        public void PrimesTest()
        {
            Assert.AreEqual(46, Length(new Primes(IntList(2, 200))));
            Assert.IsTrue(Equals(ListFromArray(2, 3, 5, 7, 11), new Primes(IntList(2, 11))));
            Assert.IsTrue(Equals(ListFromArray(2, 3, 5, 7, 11), new Primes(IntList(2, 12))));
            Assert.IsFalse(Equals(ListFromArray(2, 3, 5, 7, 11), new Primes(IntList(2, 10))));

            Assert.AreEqual(1, Length(new Primes(IntList(2, 2))));
            Assert.AreEqual(0, Length(new Primes(IntList(2, -2))));
        }

        [TestMethod]
        public void FactorialTest()
        {
            Assert.AreEqual(1, new Factorial(0).Value);
            Assert.AreEqual(1, new Factorial(1).Value);
            Assert.AreEqual(2, new Factorial(2).Value);
            Assert.AreEqual(24, new Factorial(4).Value);
        }

        [TestMethod]
        public void FibonacciTest()
        {
            Assert.AreEqual(0, new Fibonacci(0).Value);
            Assert.AreEqual(1, new Fibonacci(1).Value);
            Assert.AreEqual(1, new Fibonacci(2).Value);
            Assert.AreEqual(2, new Fibonacci(3).Value);
            Assert.AreEqual(3, new Fibonacci(4).Value);
            Assert.AreEqual(5, new Fibonacci(5).Value);
        }
    }
}
